package com.bjc.base.web;

import com.bjc.base.bean.ResultVO;
import com.bjc.base.core.ResultGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import com.bjc.base.service.IBookEvaluationReplyService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.bjc.base.bean.request.BookEvaluationReplyReqVO;
import com.bjc.base.bean.response.BookEvaluationReplyVO;

/**
 * <p>
 * 绘本评价回复 前端控制器
 * </p>
 *
 * @author 许自辉
 * @since 2018-06-10
 */
@RestController
@RequestMapping("api/book")
@Api(value = "bookEvaluationReply-api", tags = { "绘本评价回复相关接口" })
public class BookEvaluationReplyController {

    @Autowired
    private IBookEvaluationReplyService bookEvaluationReplyService;

	@ApiOperation("分页查询绘本评价回复")
	@GetMapping("bookEvaluationReply/findPage")
	public ResultVO getBookEvaluationReplyPage(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize,
			BookEvaluationReplyReqVO bookEvaluationReplyReqVO) {
		PageHelper.startPage(pageNum, pageSize);
		List<BookEvaluationReplyVO> bookEvaluationReplyVOs = bookEvaluationReplyService.getList(bookEvaluationReplyReqVO);
		return ResultGenerator.getSuccess(new PageInfo<BookEvaluationReplyVO>(bookEvaluationReplyVOs));
	}
	
	@ApiOperation("分页查询绘本评价回复")
	@GetMapping("bookEvaluationReply/find")
	public ResultVO getBookEvaluationReplye(BookEvaluationReplyReqVO bookEvaluationReplyReqVO) {
		BookEvaluationReplyVO bookEvaluationReplyVO = bookEvaluationReplyService.get(bookEvaluationReplyReqVO);
		return ResultGenerator.getSuccess(bookEvaluationReplyVO);
	}

	@ApiOperation("添加绘本评价回复")
	@PostMapping("bookEvaluationReply/create")
	public ResultVO createBookEvaluationReply(@RequestBody BookEvaluationReplyReqVO bookEvaluationReplyReqVOs) {
		int count = bookEvaluationReplyService.insert(bookEvaluationReplyReqVOs);
		return ResultGenerator.getInsertSuccess(count);
	}

	@ApiOperation("更新绘本评价回复")
	@PutMapping("bookEvaluationReply/update")
	public ResultVO updateBookEvaluationReply(@RequestBody BookEvaluationReplyReqVO bookEvaluationReplyReqVOs) {
		int count = bookEvaluationReplyService.update(bookEvaluationReplyReqVOs);
		return ResultGenerator.getUpdateSuccess(count);
	}

	@ApiOperation("批量删除绘本评价回复")
	@DeleteMapping("bookEvaluationReply/deleteList")
	public ResultVO deleteBookEvaluationReply(@ApiParam(value = "bookEvaluationReply id集合") @RequestBody int[] ids) {
		int count = bookEvaluationReplyService.deleteList(ids);
		return ResultGenerator.getDeleteSuccess(count);
	}

}
